<template>
  <div class="app-container">
    <div class="custom_card_0">
      <NewMenuTabs :list="tabs_list1" :labelStyle="{ width: '100px', paddingTop: '12px' }" name="订单状态" :column="10"
        :key="1" :active="active" @tabs_click="orderTypeChange" style="margin-bottom: 10px"></NewMenuTabs>
      <NewMenuTabs :list="tabs_list2" :labelStyle="{ width: '100px', paddingTop: '12px' }" name="订单预警" :key="2"
        :column="10" :active="active" @tabs_click="orderTypeChange"></NewMenuTabs>
    </div>
    <div class="custom_card_0" v-show="showSearch">
      <el-form inline :model="form" size="mini" ref="queryForm" label-width="120px" label-position="right">
        <div style="margin-bottom: 10px;border-bottom: 1px #DDDDDD solid">
          <el-row :gutter="10" class="mb10">

            <el-col :span="1.5">
              <el-button class="first-plain-btn" size="medium" @click="handleAdd"
                v-hasPermi="['order:orderBasic:add']">新&nbsp;&nbsp;增</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button class="sec-plain-btn" size="medium" @click="toRevenueStatistics"
                v-hasPermi="['bills:statistics:orderRevenue']">营收统计</el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button class="primary-plain-btn" size="medium" @click="showOrderSelection = true; orderType = 5"
                v-hasPermi="['order:orderBasic:delivery']">交车验车</el-button>
            </el-col>

            <el-col :span="1.5">
              <el-button class="primary-plain-btn" size="medium" @click="showOrderSelection = true; orderType = 6"
                v-hasPermi="['order:orderBasic:orderRenewal']">订单续租</el-button>
            </el-col>

            <el-col :span="1.5">
              <el-button class="primary-plain-btn" size="medium" @click="showOrderSelection = true; orderType = 7"
                v-hasPermi="['order:orderBasic:isEarlyReturn']">提前还车</el-button>
            </el-col>

            <el-col :span="1.5">
              <el-button class="primary-plain-btn" size="medium" @click="showOrderSelection = true; orderType = 8"
                v-hasPermi="['order:orderBasic:changeCar']">订单换车</el-button>
            </el-col>

            <el-col :span="1.5">
              <el-button class="primary-plain-btn" size="medium" @click="showOrderSelection = true; orderType = 9"
                v-hasPermi="['order:orderBasic:alsoCarTest']">还车验车</el-button>
            </el-col>
          </el-row>
        </div>
        <div style="display: flex">
          <div :class="{ 'min-box': !showAll }">
            <el-form-item label="订单编号" prop="orderNo">
              <el-input v-model="form.orderNo" clearable placeholder="请输入订单编号"></el-input>
            </el-form-item>
            <el-form-item label="客户信息" prop="memberName">
              <el-input v-model="form.memberName" clearable placeholder="请输入客户名称/手机号码"></el-input>
            </el-form-item>
            <el-form-item label="车牌号" prop="carNo">
              <el-input v-model="form.carNo" clearable placeholder="请输入车牌号"></el-input>
            </el-form-item>
            <el-form-item label="订单来源" prop="orderSource">
              <el-select v-model="form.orderSource" clearable>
                <template v-for="dict in dict.type.sys_order_source">
                  <el-option :label="dict.label" :value="dict.value" :key="dict.value"></el-option>
                </template>
              </el-select>
            </el-form-item>
            <el-form-item label="取车门店" prop="reserveTakeStoreId">
              <el-select v-model="form.reserveTakeStoreId" clearable>
                <el-option v-for="item in storeOptions" :key="item.storeId" :label="item.storeName"
                  :value="item.storeId" />
              </el-select>
            </el-form-item>
            <el-form-item label="还车门店" prop="reserveAlsoStoreId">
              <el-select v-model="form.reserveAlsoStoreId" clearable>
                <el-option v-for="item in storeOptions" :key="item.storeId" :label="item.storeName"
                  :value="item.storeId" />
              </el-select>
            </el-form-item>
            <el-form-item label="客户类型" prop="memberType">
              <el-select v-model="form.memberType" clearable>
                <template v-for="dict in dict.type.memberType">
                  <el-option :label="dict.label" :value="dict.value" :key="dict.value"></el-option>
                </template>
              </el-select>
            </el-form-item>
            <el-form-item label="订单标签" prop="labels">
              <el-select v-model="form.labels" clearable>
                <template v-for="dict in labelList">
                  <el-option :label="dict.name" :value="dict.id" :key="dict.id"></el-option>
                </template>
              </el-select>
            </el-form-item>
            <el-form-item label="业务员" prop="createBy">
              <el-select v-model="form.createBy" clearable>
                <el-option v-for="(item, index) in userList" :key="index" :label="item.userName" :value="item.userId" />
              </el-select>
            </el-form-item>
            <el-form-item label="下单人" prop="orderingPersonnelId">
              <el-select v-model="form.orderingPersonnelId" clearable>
                <el-option v-for="(item, index) in userList" :key="index" :label="item.userName" :value="item.userId" />
              </el-select>
            </el-form-item>
            <el-form-item label="缴费状态" prop="paymentStatus">
              <el-select v-model="form.paymentStatus" clearable>
                <el-option v-for="(item, index) in paymentStatusList" :key="index" :label="item.name"
                  :value="item.paymentStatus" />
              </el-select>
            </el-form-item>
            <el-form-item label="订单车型" prop="modelName">
              <el-input v-model="form.modelName" clearable placeholder="请输入车型关键字"></el-input>
            </el-form-item>
            <el-row>
              <el-form-item label="下单时间" prop="startTime">
                <el-date-picker clearable size="small" v-model="time" type="daterange" range-separator="至"
                  value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>
              </el-form-item>
              <el-form-item label="取消时间" prop="cancelStartTime">
                <el-date-picker clearable size="small" v-model="cancelTime" type="daterange" range-separator="至"
                  value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="预计取车时间" prop="takeStartTime">
                <el-date-picker clearable size="small" v-model="takeTime" type="daterange" range-separator="至"
                  value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>
              </el-form-item>
              <el-form-item label="预计还车时间" prop="alsoStartTime">
                <el-date-picker clearable size="small" v-model="alsoTime" type="daterange" range-separator="至"
                  value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="实际取车时间" prop="actualTakeStartTime">
                <el-date-picker clearable size="small" v-model="actualTakeTime" type="daterange" range-separator="至"
                  value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>
              </el-form-item>
              <el-form-item label="实际还车时间" prop="actualAlsoStartTime">
                <el-date-picker clearable size="small" v-model="actualAlsoTime" type="daterange" range-separator="至"
                  value-format="yyyy-MM-dd" start-placeholder="开始时间" end-placeholder="结束时间"></el-date-picker>
              </el-form-item>
            </el-row>
          </div>
          <div style="align-self: flex-end">
            <el-form-item style="width: 220px !important;">
              <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
              <el-button type="text" size="mini" @click="showAll = !showAll; resetQueruyForm()">{{ showAll ? '收起' : '展开'
                }}<i :class="showAll ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i></el-button>
            </el-form-item>
          </div>
        </div>

      </el-form>
    </div>
    <div class="custom_card">
      <el-row :gutter="10" class="mb10">
        <el-col :span="1.5">
          <el-button class="first-plain-btn" size="medium" icon="el-icon-download" :loading="exportLoading"
            @click="handleExport" v-hasPermi="['order:orderBasic:export']">导出
          </el-button>
        </el-col>


        <right-toolbar :showFolding="true" :showSearch.sync="showSearch" :lineFolding.sync="lineFolding"
          @queryTable="getList" :columns="columns"></right-toolbar>
      </el-row>

      <el-table v-loading="loading" :data="list" border :row-class-name="tableRowClassName"
        @sort-change="handleSortChange">
        <el-table-column label="订单编号" v-if="columns[0].visible" align="center" min-width="200" show-overflow-tooltip>
          <template slot-scope="{ row }">
            <span style="font-size: 14px; color: #1890ff;cursor:pointer;" @click="handleDetail(row)">{{ row.orderNo
              }}</span>
            <template v-if="row.afterOrderNumber">
              <div class="oederNo-badge oederNo-badge-red"></div>
              <div class="oederNo-badge-text">换</div>
            </template>
            <template v-else-if="row.previousOrderNumber">
              <div class="oederNo-badge oederNo-badge-green"></div>
              <div class="oederNo-badge-text">换</div>
            </template>
          </template>
        </el-table-column>
        <el-table-column label="承租人" v-if="columns[1].visible" align="center" min-width="130" show-overflow-tooltip>
          <template slot-scope="{ row }">
            <div v-if="lineFolding">
              {{ row.memberName }}
              <div>{{ row.memberPhone }}</div>
              <span v-if="row.memberType == 1">{{ row.enterpriseName }}</span>
              <span v-else>个人客户</span>
            </div>

            <span v-else>{{ row.memberName }}&nbsp;&nbsp;{{ row.memberPhone }}&nbsp;&nbsp;
              <span v-if="row.memberType == 1">{{ row.enterpriseName }}</span>
              <span v-else>个人客户</span>
            </span>
          </template>
        </el-table-column>

        <el-table-column label="取车信息" v-if="columns[2].visible" align="center" min-width="240" show-overflow-tooltip
          prop="startTime" sortable="custom">
          <template slot-scope="{ row }">
            <span :style="{ color: row.orderStatus == 10 ? '#999' : '#d9001b' }">{{ {
              1: '到店取车 ', 3: '上门送车 ', 4: '上门送车 ', 5: '到店取车
              ',}[Number(row.rentalType)] }}</span>
            <div v-if="lineFolding">
              <div>{{ row.reserveTakeStoreName }}</div>
              <span>{{ row.startTime }}</span>
            </div>
            <span v-else> {{ row.reserveTakeStoreName }}&nbsp;&nbsp;&nbsp;
              <span>{{ row.startTime }}</span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="还车信息" v-if="columns[3].visible" align="center" min-width="240" show-overflow-tooltip
          prop="rentalEndTime" sortable="custom">
          <template slot-scope="{ row }">
            <span :style="{ color: row.orderStatus == 10 ? '#999' : '#dd5d1b' }">{{ {
              1: '到店还车 ', 3: '上门还车 ', 4: '到店还车 ', 5: '上门还车
              ',}[Number(row.rentalType)] }}</span>
            <div v-if="lineFolding">
              <div>{{ row.reserveAlsoStoreName }}</div>
              <span>{{ row.endTime }}</span>
            </div>
            <span v-else> {{ row.reserveAlsoStoreName }}&nbsp;&nbsp;&nbsp;
              <span>{{ row.endTime }}</span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="押金方式" v-if="columns[4].visible" align="center" min-width="130" show-overflow-tooltip>
          <template slot-scope="{ row }">
            <span>{{ row.depositPayType == 1 ? '线上支付' : '线下支付' }}</span>
            <span v-if="row.depositIspay > 2" :style="{ display: lineFolding ? 'block' : 'inline-block' }">车辆押金：¥{{
              row.deposit
            }}</span>
            <span v-if="row.illegalIspay > 2" :style="{ display: lineFolding ? 'block' : 'inline-block' }">违章押金：¥{{
              row.illegalDeposit }} </span>
          </template>
        </el-table-column>
        <el-table-column label="租期/租金总额" v-if="columns[5].visible" align="center" min-width="140" show-overflow-tooltip>
          <template slot-scope="{ row }">
            <div>{{ row.actualLeaseDays }}天/¥{{ row.rent + row.renewCost }}</div>
          </template>
        </el-table-column>

        <el-table-column label="预定车型" v-if="columns[6].visible" align="center" prop="modelName" min-width="130"
          show-overflow-tooltip />
        <el-table-column label="车牌号" v-if="columns[7].visible" align="center" prop="carNo" min-width="130"
          show-overflow-tooltip>
          <template slot-scope="{ row }">
            <template v-if="row.orderClassify == 1">
              <span v-if="row.carNo" :class="row.carNo.length > 7 ? 'car_no_new' : 'car_no'" @click="handlePeiche(row)">
                {{ row.carNo.substr(0, 2) }}<b class="dian">·</b>{{ row.carNo.substr(2) }}
              </span>
              <span v-else-if="checkPermi(['order:otaOrder:dispatchCar'])"
                style="font-size: 14px; color: #1890ff;cursor:pointer;" @click="handlePeiche(row)">{{ '点击排车' }}</span>
              <span v-else style="font-size: 14px;">/</span>
            </template>
            <template v-else>
              <span v-if="row.carNo" :class="row.carNo.length > 7 ? 'car_no_new' : 'car_no'" @click="handlePeiche(row)">
                {{ row.carNo.substr(0, 2) }}<b class="dian">·</b>{{ row.carNo.substr(2) }}
              </span>
              <span v-else-if="row.orderStatus < 4" style="font-size: 14px; color: #1890ff;cursor:pointer;"
                @click="handlePeiche(row)">{{ '点击排车' }}</span>
              <span style="font-size: 14px;" v-else>/</span>
            </template>

          </template>
        </el-table-column>
        <el-table-column label="订单状态" v-if="columns[8].visible" align="center" min-width="200" show-overflow-tooltip
          prop="orderStatus">
          <template slot-scope="{ row }">
            <span style="display: inline-block">
              <span>
                <dict-tag style="display: inline-block" :options="dict.type.sys_order_status"
                  :value="row.orderStatus" />
              </span>

              <span v-if="row.orderStatus == 0 && row.orderSource == 1"
                :style="{ display: lineFolding ? 'block' : 'inline-block' }" style="margin-left: 4px">
                <count-down :endTime="row.payEndTime" :nowTime="row.nowTime" endText="超时未支付" startText="支付剩余时间" />
              </span>

              <span v-if="row.orderStatus > 0 && row.orderStatus < 4"
                :style="{ display: lineFolding ? 'block' : 'inline-block' }" style="margin-left: 4px">
                <count-down :endTime="row.rentalStartTime" :nowTime="row.nowTime" endText="超时未取车" startText="距离取车时间" />
              </span>

              <span v-if="row.orderStatus == 4" :style="{ display: lineFolding ? 'block' : 'inline-block' }"
                style="margin-left: 4px">
                <count-down :endTime="row.rentalEndTime" :nowTime="row.nowTime" endText="超时未还车" startText="距离还车时间" />
              </span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="订单来源" v-if="columns[9].visible" align="center" min-width="130" show-overflow-tooltip>
          <template slot-scope="{ row }">
            <dict-tag :options="dict.type.sys_order_source" :value="row.orderSource" />
          </template>
        </el-table-column>
        <el-table-column label="下单人" v-if="columns[10].visible" align="center" prop="orderingPersonnelName"
          min-width="130" show-overflow-tooltip>
          <template slot-scope="{ row }"> {{ row.orderingPersonnelName || '/' }}</template>
        </el-table-column>
        <el-table-column label="订单标签" v-if="columns[11].visible" align="center" min-width="130" show-overflow-tooltip
          prop="labels">
          <template slot-scope="{ row }">
            {{ formatLabel(row.labels) || '/' }}
          </template>
        </el-table-column>
        <el-table-column label="业务员" v-if="columns[12].visible" align="center" min-width="130" show-overflow-tooltip
          prop="salesman">
          <template slot-scope="{ row }">
            <div v-if="lineFolding" style="font-size: 14px; color: #1890ff;cursor:pointer;" @click="handleDingdan(row)">
              <div>负责人:{{ row.headName || '/' }}</div>
              <div>发车员:{{ row.salesman || '/' }}</div>
              <div>收车员:{{ row.vehicleCollector || '/' }}</div>
            </div>
            <span v-else style="font-size: 14px; color: #1890ff;cursor:pointer;" @click="handleDingdan(row)">
              <span>负责人:{{ row.headName || '/' }}</span>&nbsp;&nbsp;&nbsp;
              <span>发车员:{{ row.salesman || '/' }}</span>&nbsp;&nbsp;&nbsp;
              <span>收车员:{{ row.vehicleCollector || '/' }}</span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="下单时间" v-if="columns[13].visible" align="center" min-width="130" show-overflow-tooltip
          prop="createTime" sortable="custom" />
        <el-table-column label="说明" v-if="columns[14].visible" align="center" min-width="300" prop="orderRemarks">
          <template slot-scope="{ row }">
            <el-popover v-if="row.lastOrderRemark" placement="top-start" width="400" trigger="hover">
              <div class="el-card is-always-shadow" v-for="(item, index) in row.orderRemarks" :key="index">
                <div class="el-card__body">
                  <div>{{ item.remarkContent }}</div>
                  <p style="font-size: 12px;color: #666666">{{ item.operatorName }}&nbsp;&nbsp;提交于 {{ item.createTime }}
                  </p>
                </div>
              </div>
              <el-button slot="reference" type="text"
                style="width: 100%;overflow: hidden;text-overflow: ellipsis; white-space: nowrap;"
                @click="remarkForm.orderNo = row.orderNo; dialogVisibleOrderRemark = true">{{ row.lastOrderRemark }}
              </el-button>
            </el-popover>
            <el-button v-else type="text" style="width: 100%"
              @click="remarkForm.orderNo = row.orderNo; dialogVisibleOrderRemark = true">/</el-button>
          </template>
        </el-table-column>
        <el-table-column label="取消时间" v-if="columns[15].visible" align="center" min-width="130" show-overflow-tooltip
          prop="cancelTime" />

        <el-table-column label="操作" width="150" fixed="left" align="center">
          <!-- 订单状态（0=待支付,1=待分配,2=待排车,3=待取车,4=用车中,5=车损结算,6=押金结算,7=违章处理,8=违章结算,9=已完成,10=已取消,11=结算退款中） -->
          <template slot-scope="{ row }">
            <template v-if="row.orderClassify == 1">
              <el-button type="text" size="mini" @click="handleDetail(row)">订单详情</el-button>
              <el-dropdown size="mini" @command="(command) => handleCommand(command, row)">
                <span class="el-dropdown-link"> <i class="el-icon-d-arrow-right el-icon--right"></i>更多</span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="handleDingdan"
                    v-if="(row.headName == null || row.salesman == null || row.vehicleCollector == null) && checkPermi(['order:otaOrder:salesman'])"
                    icon="el-icon-search">分配业务员
                  </el-dropdown-item>
                  <el-dropdown-item command="handlePeiche" v-if="checkPermi(['order:otaOrder:dispatchCar'])"
                    icon="el-icon-search">订单排车</el-dropdown-item>
                  <el-dropdown-item command="otaTakeCar"
                    v-if="row.isCheckCar == 1 && checkPermi(['order:otaOrder:takeCar'])"
                    icon="el-icon-search">交车验车</el-dropdown-item>
                  <el-dropdown-item command="otaReturnCar"
                    v-if="row.isCheckCar == 2 && checkPermi(['order:otaOrder:returnCar'])"
                    icon="el-icon-search">还车验车</el-dropdown-item>
                  <el-dropdown-item command="otaCostAdditional" icon="el-icon-search"
                    v-if="(row.orderStatus == 4 || row.orderStatus == 9) && checkPermi(['order:otaOrder:supplementaryPayment'])">费用补录
                  </el-dropdown-item>
                  <el-dropdown-item command="handleLog" icon="el-icon-search"
                    v-hasPermi="['order:orderBasic:log']">订单日志</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
            <template v-else>
              <el-button type="text" size="mini" @click="handleEdit(row)"
                v-if="row.orderStatus == 0 && row.rentIspay == 1 && row.depositIspay == 1 && row.illegalIspay == 1 && checkPermi(['order:orderBasic:edit'])">编辑订单</el-button>
              <el-button type="text" size="mini" @click="paymentOfFees(row)"
                v-else-if="row.orderStatus == 0 && checkPermi(['order:orderBasic:paymentOfFees'])">费用缴纳</el-button>
              <el-button type="text" size="mini" @click="handleDingdan(row)"
                v-if="row.orderStatus == 1 && checkPermi(['order:orderBasic:distribution'])">分配人员</el-button>
              <el-button type="text" size="mini" @click="handlePeiche(row)"
                v-if="row.orderStatus == 2 && checkPermi(['order:orderBasic:supplyCar'])">订单排车</el-button>
              <el-button type="text" size="mini" @click="handleJiaocheyanche(row)"
                v-if="row.orderStatus == 3 && checkPermi(['order:orderBasic:delivery'])">交车验车</el-button>
              <el-button type="text" size="mini" @click="handleHuancheyanche(row)"
                v-if="row.orderStatus == 4 && checkPermi(['order:orderBasic:alsoCarTest'])">还车验车</el-button>
              <el-button type="text" size="mini" @click="handleVehicleDamage(row)"
                v-if="row.orderStatus == 5 && checkPermi(['order:orderBasic:vehicleDamage'])">车损结算</el-button>
              <el-button type="text" size="mini" @click="handleDepositRefund(row)"
                v-if="row.orderStatus == 6 && checkPermi(['order:orderBasic:depositRefund'])">押金结算</el-button>
              <el-button type="text" size="mini" @click="handleIllegalProcessing(row)"
                v-if="row.orderStatus == 7 && checkPermi(['order:orderBasic:handViolations'])">违章处理
              </el-button>
              <el-button type="text" size="mini" @click="handleIllegalRefund(row)"
                v-if="row.orderStatus == 8 && checkPermi(['order:orderBasic:IllegalProcessing'])">违章结算
              </el-button>
              <el-button type="text" size="mini" @click="handleDetail(row)"
                v-if="row.orderStatus > 8 && checkPermi(['order:orderBasic:query'])">订单详情</el-button>
              <el-dropdown size="mini" @command="(command) => handleCommand(command, row)"
                v-hasPermi="['order:orderBasic:costDetail', 'order:orderBasic:log', 'order:orderBasic:query',]">
                <span class="el-dropdown-link"> <i class="el-icon-d-arrow-right el-icon--right"></i>更多</span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="handleEdit"
                    v-if="row.orderStatus < 4 && row.orderStatus > 0 && row.rentIspay == 1 && row.depositIspay == 1 && row.illegalIspay == 1 && checkPermi(['order:orderBasic:edit'])"
                    icon="el-icon-search">编辑订单
                  </el-dropdown-item>
                  <el-dropdown-item command="handleUpdateDriver" icon="el-icon-search"
                    v-if="charterService == 1 && row.isSubstituteDriving == 1 && row.orderStatus <= 4 && checkPermi(['order:orderBasic:updateDriver'])">改排司机</el-dropdown-item>
                  <el-dropdown-item command="paymentOfFees"
                    v-if="((row.orderStatus > 0) || (row.orderStatus == 0 && row.rentIspay == 1 && row.depositIspay == 1 && row.illegalIspay == 1)) && checkPermi(['order:orderBasic:paymentOfFees'])"
                    icon="el-icon-search">费用缴纳
                  </el-dropdown-item>
                  <el-dropdown-item command="handleCancel"
                    v-if="row.orderStatus < 4 && checkPermi(['order:orderBasic:cancel'])"
                    icon="el-icon-search">取消订单</el-dropdown-item>
                  <el-dropdown-item command="handleDepositRefund"
                    v-if="row.orderStatus == 5 && checkPermi(['order:orderBasic:depositRefund'])"
                    icon="el-icon-search">押金结算
                  </el-dropdown-item>
                  <el-dropdown-item command="handleIllegalRefund"
                    v-if="row.orderStatus == 7 && checkPermi(['order:orderBasic:IllegalProcessing'])"
                    icon="el-icon-search">违章结算
                  </el-dropdown-item>
                  <el-dropdown-item command="handleDingdan"
                    v-if="row.orderStatus != 1 && row.orderStatus < 5 && checkPermi(['order:orderBasic:distribution'])"
                    icon="el-icon-search">{{ row.salesman ? "重新分配" : "订单分配" }}</el-dropdown-item>
                  <el-dropdown-item command="handlePeiche"
                    v-if="row.orderStatus != 2 && row.orderStatus < 4 && checkPermi(['order:orderBasic:supplyCar'])"
                    icon="el-icon-search">{{ row.carNo ? '重新排车' : '订单排车' }} </el-dropdown-item>
                  <el-dropdown-item command="earlyReturn"
                    v-if="row.orderStatus == 4 && row.isEarlyReturn != 1 && checkPermi(['order:orderBasic:isEarlyReturn'])"
                    icon="el-icon-search">提前还车
                  </el-dropdown-item>
                  <el-dropdown-item command="changeCar"
                    v-if="row.orderStatus == 4 && checkPermi(['order:orderBasic:changeCar'])"
                    icon="el-icon-search">订单换车</el-dropdown-item>
                  <el-dropdown-item command="orderRenewal"
                    v-if="row.orderStatus == 4 && row.isEarlyReturn != 1 && checkPermi(['order:orderBasic:orderRenewal'])"
                    icon="el-icon-search">订单续租
                  </el-dropdown-item>
                  <el-dropdown-item command="setLabel" icon="el-icon-search"
                    v-if="row.orderStatus != 10 && checkPermi(['order:orderBasic:setLabel'])">设置标签</el-dropdown-item>
                  <el-dropdown-item command="newExpenses" icon="el-icon-search"
                    v-if="row.orderStatus != 10 && checkPermi(['order:orderBasic:newExpenses', 'order:orderBasic:addExpenses'])">租金调整
                  </el-dropdown-item>
                  <el-dropdown-item command="handleDetail" icon="el-icon-search"
                    v-if="row.orderStatus < 8 && checkPermi(['order:orderBasic:query'])">订单详情</el-dropdown-item>
                  <el-dropdown-item command="printContract"
                    v-if="row.printContractUrl != null && checkPermi(['order:orderBasic:printContract'])"
                    icon="el-icon-search">订单合同
                  </el-dropdown-item>
                  <el-dropdown-item command="cargps"
                    v-if="row.orderStatus == 4 && row.deviceNo && checkPermi(['car:basic:list'])"
                    icon="el-icon-search">车辆监控</el-dropdown-item>
                  <el-dropdown-item command="handleLog" icon="el-icon-search"
                    v-hasPermi="['order:orderBasic:log']">订单日志</el-dropdown-item>
                  <el-dropdown-item command="handleJiaocheyanchelist" icon="el-icon-search"
                    v-if="row.orderStatus > 3 && row.orderStatus != 10 && checkPermi(['order:orderBasic:deliveryInfo'])">交车验车单
                  </el-dropdown-item>
                  <el-dropdown-item command="handleHuancheyanchelist" icon="el-icon-search"
                    v-if="row.orderStatus > 4 && row.orderStatus != 10 && checkPermi(['order:orderBasic:alsoCarTest'])">还车验车单
                  </el-dropdown-item>
                  <el-dropdown-item command="handleDelete" v-if="checkPermi(['order:orderBasic:delete'])"
                    icon="el-icon-search">删除订单</el-dropdown-item>
                  <el-dropdown-item command="handleRevised" v-if="checkPermi(['order:orderBasic:revised'])"
                    icon="el-icon-search">修正数据</el-dropdown-item>
                  <el-dropdown-item command="handleUpdateMember" v-if="checkPermi(['member:basic:edit'])"
                    icon="el-icon-search">客户信息</el-dropdown-item>

                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total > 0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" @pagination="getList" />
    </div>

    <el-dialog title="订单分配" :visible.sync="showdingdanfenpei" width="1200px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <MmvDingdanfenpei ref="MmvDingdanfenpei" v-if="showdingdanfenpei" :orderNo="nowOrderNo"
        :reserveTakeStoreId="reserveTakeStoreId" :reserveAlsoStoreId="reserveAlsoStoreId"
        @close="showdingdanfenpei = false"></MmvDingdanfenpei>
      <div slot="footer">
        <el-button @click="showdingdanfenpei = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="费用缴纳" :visible.sync="showPaymentOfFees" width="1200px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <el-table v-loading="loading" :data="paymentOfFeesList" @selection-change="handleSelectionChange" border>
        <el-table-column type="selection" :selectable="selectable" width="55" align="center" />
        <el-table-column label="收费项目" align="center" prop="remark" />
        <el-table-column label="应收金额" align="center" prop="cost" />
        <el-table-column label="已收金额" align="center" prop="paidAmount" />
        <el-table-column label="待收金额" align="center" prop="unpaidAmount" />
      </el-table>
      <div slot="footer">
        <el-button type="primary" :disabled="multiple" @click="payImmediately()">立即缴费</el-button>
        <el-button @click="showPaymentOfFees = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="取消订单" :visible.sync="showorderRefund" width="1200px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <MmvOrderRefund ref="MmvOrderRefund" v-if="showorderRefund" :orderNo="nowOrderNo"
        @close="showorderRefund = false">
      </MmvOrderRefund>
    </el-dialog>

    <el-dialog title="去配车" :visible.sync="showpeiche" width="1000px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <MmvPeiche ref="MmvPeiche" v-if="showpeiche" :orderNo="nowOrderNo" @close="showpeiche = false"
        @show="showpeiche = true" :rent="xbRent" :lease-days="xbLeaseDays"></MmvPeiche>
      <div slot="footer">
        <el-button @click="showpeiche = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="提前还车" :visible.sync="showEarlyReturn" width="1200px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <MmvEarlyReturn ref="MmvEarlyReturn" v-if="showEarlyReturn" :orderNo="nowOrderNo"
        @close="showEarlyReturn = false">
      </MmvEarlyReturn>
    </el-dialog>
    <el-dialog title="订单换车" :visible.sync="showChangeCar" width="1200px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <MmvChangeCar ref="MmvChangeCar" v-if="showChangeCar" :orderNo="nowOrderNo" @close="showChangeCar = false">
      </MmvChangeCar>
    </el-dialog>

    <el-dialog title="订单续租" :visible.sync="showOrderRenewal" width="1200px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <MmvOrderRenewal ref="MmvOrderRenewal" v-if="showOrderRenewal" :orderNo="nowOrderNo"
        @close="showOrderRenewal = false"></MmvOrderRenewal>
    </el-dialog>


    <el-dialog title="设置标签" :visible.sync="showSetLabel" width="500px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <el-form ref="elForm" :model="setLabelData" size="medium" label-width="80px">
        <el-form-item label="订单标签" prop="labels">
          <el-select v-model="setLabelData.labels" multiple placeholder="请选择订单标签" clearable :style="{ width: '100%' }">
            <el-option v-for="item in labelList" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="toSetLabel" type="primary">保存</el-button>
        <el-button @click="showSetLabel = false">取消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="租金调整" :visible.sync="showNewExpenses" width="1100px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <MmvCostAdjustment ref="MmvCostAdjustment" v-if="showNewExpenses" :orderNo="nowOrderNo"
        @close="showNewExpenses = false"></MmvCostAdjustment>
    </el-dialog>

    <el-dialog title="费用补录" :visible.sync="showOTACostAddition" width="1100px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <OTACostAdditional ref="OTACostAdditional" v-if="showOTACostAddition" :orderNo="nowOrderNo"
        @close="showOTACostAddition = false"></OTACostAdditional>
    </el-dialog>

    <el-dialog title="交车验车单" :visible.sync="showjiaocheyanchelist" width="1000px" destroy-on-close append-to-body
      @close="closeDiolog(false)">
      <MmvDeliveryList ref="MmvDeliveryList" v-if="showjiaocheyanchelist" :orderNo="nowOrderNo" :type="1"
        @close="showjiaocheyanchelist = false"></MmvDeliveryList>
      <div slot="footer">
        <el-button @click="showjiaocheyanchelist = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="还车验车单" :visible.sync="huancheyanchelist" width="1000px" destroy-on-close append-to-body
      @close="closeDiolog(false)">
      <MmvDeliveryList ref="MmvDeliveryList" v-if="huancheyanchelist" :orderNo="nowOrderNo" :type="2"
        @close="huancheyanchelist = false"></MmvDeliveryList>
      <div slot="footer">
        <el-button @click="huancheyanchelist = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-drawer title="订单日志" :visible.sync="showdingdanlog" direction="rtl" size="30%">
      <MmvLog ref="MmvLog" v-if="showdingdanlog" :orderNo="nowOrderNo" :type="11"></MmvLog>
    </el-drawer>

    <el-dialog title="车损结算" :visible.sync="showVehicleDamage" width="1000px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <VehicleDamage ref="VehicleDamage" v-if="showVehicleDamage" :orderNo="nowOrderNo"
        @close="showVehicleDamage = false; closeDiolog(true)"></VehicleDamage>
    </el-dialog>

    <el-dialog title="车辆押金结算" :visible.sync="showDepositRefund" width="1000px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <DepositRefund ref="DepositRefund" v-if="showDepositRefund" :orderNo="nowOrderNo"
        @close="showDepositRefund = false; closeDiolog(true)"></DepositRefund>
    </el-dialog>

    <el-dialog :title="refundConfirmTitle" :visible.sync="showDepositRefundConfirm" width="1000px" destroy-on-close
      append-to-body @close="closeDiolog(true)">
      <MmvRefundConfirm ref="MmvRefundConfirm" v-if="showDepositRefundConfirm" :orderNo="nowOrderNo"
        :type="refundConfirmType" @close="showDepositRefundConfirm = false"></MmvRefundConfirm>
    </el-dialog>

    <el-dialog title="违章处理" :visible.sync="showIllegalProcessing" width="1000px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <IllegalProcessing ref="IllegalProcessing" v-if="showIllegalProcessing" :orderNo="nowOrderNo"
        @close="showIllegalProcessing = false"></IllegalProcessing>
    </el-dialog>

    <el-dialog title="违章押金结算" :visible.sync="showIllegalRefund" width="1000px" destroy-on-close append-to-body
      @close="closeDiolog(true)">
      <IllegalRefund ref="IllegalProcessing" v-if="showIllegalRefund" :orderNo="nowOrderNo"
        @close="showIllegalRefund = false"></IllegalRefund>
    </el-dialog>

    <el-dialog :visible.sync="imgVisble" width="70%" class="imgVisble" :close-on-click-modal="false">
      <iframe :src="imgVisbleUrl" frameborder="0" width="100%" height="600"></iframe>
    </el-dialog>

    <!-- 导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body class="uploadBox">
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag><i
          class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip"><span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
            @click="importTemplate">下载模板
          </el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="选择订单" :visible.sync="showOrderSelection" width="80vw" top="5vh !important" destroy-on-close
      append-to-body>
      <OrderSelection ref="MmvCarSelection" v-if="showOrderSelection" @handleCommand="handleCommand" :type="orderType">
      </OrderSelection>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showOrderSelection = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="提交订单说明" :visible.sync="dialogVisibleOrderRemark" width="30%">
      <div>
        <el-form ref="remarkForm" :model="remarkForm" label-width="80px" :rules="remarkFormRules">
          <el-form-item label="说明" prop="remarkContent">
            <el-input type="textarea" v-model="remarkForm.remarkContent" maxlength="500" rows="10" placeholder="请输入订单说明"
              show-word-limit></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleOrderRemark = false">取 消</el-button>
        <el-button type="primary" @click="commitOrderRemark">确 定</el-button>
      </span>
    </el-dialog>

    <!--  司机列表-->
    <el-dialog title="选择司机" :visible.sync="showDriver" width="1000px" destroy-on-close append-to-body
      @close="showDriver = false">
      <choose-driver ref="chooseDriver" :storeId="reserveTakeStoreId" v-if="showDriver"
        @success="updateDriver"></choose-driver>
      <div slot="footer">
        <el-button @click="showDriver = false">关闭
        </el-button>
      </div>
    </el-dialog>

    <el-dialog title="修正订单数据" :visible.sync="revisedOrderDataFlag" :close-on-click-modal="false" width="50%">
      <div>
        <el-form ref="revisedOrderDataForm" :model="revisedOrderDataForm" label-width="130px" :inline="true"
          class="demo-form-inline">
          <el-row :gutter="15">
            <el-form-item label="预约取车时间" prorevisedOrderDataFormp="rentalStartTime">
              <el-date-picker v-model="revisedOrderDataForm.rentalStartTime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择预约取车时间" type="datetime" format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
            </el-form-item>
            <el-form-item label="预约还车时间" prop="rentalEndTime">
              <el-date-picker v-model="revisedOrderDataForm.rentalEndTime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择预约还车时间" type="datetime" format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
            </el-form-item>
          </el-row>
          <el-row :gutter="15">
            <el-form-item label="实际取车时间" prop="actualStartTime">
              <el-date-picker v-model="revisedOrderDataForm.actualStartTime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择实际取车时间" type="datetime" format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
            </el-form-item>
            <el-form-item label="实际还车时间" prop="actualEndTime">
              <el-date-picker v-model="revisedOrderDataForm.actualEndTime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择实际还车时间" type="datetime" format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
            </el-form-item>
          </el-row>
          <el-row :gutter="15">
            <el-form-item label="预定租赁天数" prop="leaseDays" :rules="[{ type: 'number', message: '必须为数字值' }]">
              <el-input v-model.number="revisedOrderDataForm.leaseDays" placeholder="请输入预定租赁天数"></el-input>
            </el-form-item>
            <el-form-item label="实际租赁天数" prop="actualLeaseDays" :rules="[{ type: 'number', message: '必须为数字值' }]">
              <el-input v-model.number="revisedOrderDataForm.actualLeaseDays" placeholder="请输入实际租赁天数"></el-input>
            </el-form-item>
          </el-row>
          <el-row :gutter="15">
            <el-form-item label="取车公里数" prop="leaseDays" :rules="[{ type: 'number', message: '必须为数字值' }]">
              <el-input v-model.number="revisedOrderDataForm.takeCarMileage" placeholder="请输入取车公里数"></el-input>
            </el-form-item>
            <el-form-item label="还车公里数" prop="leaseDays" :rules="[{ type: 'number', message: '必须为数字值' }]">
              <el-input v-model.number="revisedOrderDataForm.returnCarMileage" placeholder="请输入还车公里数"></el-input>
            </el-form-item>
          </el-row>
          <el-row :gutter="15">
            <el-form-item label="取车油量" prop="takeCarFuelCapacity">
              <el-slider v-model="revisedOrderDataForm.takeCarFuelCapacity"
                style="width: 140px;display: inline-block;margin: 0 20px" :max="16" show-stops></el-slider>
              <div style="display: inline-block;overflow: hidden">{{ revisedOrderDataForm.takeCarFuelCapacity }}/16
              </div>
            </el-form-item>
            <el-form-item label="还车油量" prop="returnCarFuelCapacity">
              <el-slider v-model="revisedOrderDataForm.returnCarFuelCapacity"
                style="width:140px;display: inline-block;margin: 0 20px" :max="16" show-stops></el-slider>
              <div style="display: inline-block;overflow: hidden">{{ revisedOrderDataForm.returnCarFuelCapacity }}/16
              </div>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="revisedOrderDataFlag = false">取 消</el-button>
        <el-button type="primary" @click="doRevisedOrderData">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 添加或修改会员基础信息对话框 -->

    <el-dialog title="修改会员基础信息" :visible.sync="editMemberInfo" width="1100px" destroy-on-close append-to-body>
      <MemberAdd ref="MemberAdd" v-if="editMemberInfo" :editid="memberNo"
        :electronic-contract-enable="electronicContractEnable"></MemberAdd>
      <div slot="footer" v-if="editMemberInfo">
        <el-button @click="editMemberInfo = false">取消</el-button>
        <el-button type="primary" @click="ditMemberSubit()" :loading="submitLoading">确定
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as api from '@/api/order/index'
import { getAllStore } from '@/api/store/store'
import MmvAdd from './add.vue'
import MmvDetail from './detail.vue'
import MmvPeiche from './pageche.vue'
import MmvDingdanfenpei from './dingdanfenpei.vue'
import MmvDelivery from './delivery.vue'
import MmvDeliveryList from './delivery-detail.vue'
import MmvOrderRefund from './orderRefund.vue'
import MmvEarlyReturn from './earlyReturn.vue'
import MmvChangeCar from './changeCar.vue'
import MmvOrderRenewal from './orderRenewal.vue'
import MmvCostAdjustment from './costAdjustment.vue'
import OTACostAdditional from './otaCostAdditional.vue'
import MmvLog from './log.vue'
import IllegalProcessing from './IllegalProcessing.vue'
import MmvRefundConfirm from './depositRefundConfirm.vue'
import IllegalRefund from './IllegalRefund.vue'
import DepositRefund from './depositRefund.vue'
import VehicleDamage from './vehicleDamage.vue'
import OrderSelection from './orderSelection.vue'
import PingZheng from '../../components/zhifupingzheng.vue'
import countDown from './components/countDown.vue'
import NewMenuTabs from '@/components/custom/newMenuTabs.vue'
import { getToken } from '@/utils/auth'
import { getAllLabel } from "@/api/label/label";
import { userlist } from '@/api/system/user'
import { checkPermi } from '@/utils/permission'
import Cookies from 'js-cookie'
import ChooseDriver from "./components/chooseDriver.vue"
import { rescheduleDriver } from "@/api/order/index";
import { illegalQueryPriceDetail } from "@/api/credit/credit";
import MemberAdd from '@/views/member/add.vue'
import { updateBasic } from "@/api/member/member";
export default {
  name: 'Order',
  components: {
    MmvAdd,
    MemberAdd,
    MmvDetail,
    MmvPeiche,
    MmvDingdanfenpei,
    MmvDelivery,
    MmvDeliveryList,
    MmvOrderRefund,
    MmvLog,
    IllegalProcessing,
    VehicleDamage,
    DepositRefund,
    PingZheng,
    MmvRefundConfirm,
    IllegalRefund,
    countDown,
    MmvEarlyReturn,
    MmvChangeCar,
    MmvOrderRenewal,
    MmvCostAdjustment,
    NewMenuTabs,
    OrderSelection,
    OTACostAdditional,
    ChooseDriver
  },
  dicts: ['memberType', 'sys_order_source', 'sys_order_status', 'rental_type'],
  data() {
    return {
      //修改客户信息
      electronicContractEnable: 0,
      memberNo: null,
      editMemberInfo: null,
      submitLoading: false,

      showDriver: false,
      showOTACostAddition: false,
      dialogVisibleOrderRemark: false,
      remarkForm: {
        orderNo: null,
        remarkContent: '',
      },
      remarkFormRules: {
        remarkContent: [
          { required: true, message: '请输入订单说明', trigger: 'blur' }
        ],
      },
      revisedOrderDataFlag: false,
      revisedOrderDataForm: {
        orderNo: null,
        rentalStartTime: null,
        rentalEndTime: null,
        actualStartTime: null,
        actualEndTime: null,
        leaseDays: null,
        actualLeaseDays: null,
        takeCarMileage: null,
        returnCarMileage: null,
        takeCarFuelCapacity: null,
        returnCarFuelCapacity: null,
      },
      revisedOrderDataRules: {
      },

      xbRent: null,
      xbLeaseDays: null,
      paymentStatusList: [
        {
          name: '全部订单',
          paymentStatus: 0
        },
        {
          name: '押金待缴订单',
          paymentStatus: 1
        },
        {
          name: '租金待缴订单',
          paymentStatus: 2
        },
        {
          name: '全部缴清订单',
          paymentStatus: 3
        }
      ],
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: '',
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {
          Authorization: 'Bearer ' + getToken()
        },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/order/orderBasic/import'
      },

      showOrderSelection: false,
      orderType: 0,
      showAll: false,
      overPng: require('@/assets/images/over.png'),
      scheduledData: {},
      userList: [],
      labelList: [],
      setLabelData: {
        orderNo: "",
        labels: []
      },
      pingzheng: {
        title: '',
        show: false,
        bizType: 0
      },
      addLoadIng: false,
      tabs_list1: [
        {
          key: '1',
          name: '全部',
          count: 0
        },
        {
          key: '2',
          name: '待支付',
          count: 0
        },
        {
          key: '3',
          name: '待分配',
          count: 0
        },
        {
          key: '4',
          name: '待排车',
          count: 0
        },
        {
          key: '5',
          name: '待取车',
          count: 0
        },
        {
          key: '6',
          name: '用车中',
          count: 0
        },
        {
          key: '7',
          name: '结算中',
          count: 0
        },
        {
          key: '8',
          name: '已完成',
          count: 0
        },
        {
          key: '9',
          name: '已取消',
          count: 0
        }
        // {
        //   key: '10',
        //   name: '已退款',
        //   count: 0,
        // },
      ],
      tabs_list2: [
        {
          key: '11',
          name: '今日待取车',
          count: 0
        },

        {
          key: '13',
          name: '今日待还车',
          count: 0
        },
        {
          key: '12',
          name: '2小时内待取车',
          count: 0
        },
        {
          key: '14',
          name: '2小时内待还车',
          count: 0
        },
        {
          key: '15',
          name: '逾期未取车',
          count: 0
        },
        {
          key: '16',
          name: '逾期未还车',
          count: 0
        },
        {
          key: '17',
          name: '2小时内取车-车辆整备预警',
          count: 0
        }
      ],
      // 列信息
      columns: [
        { key: 0, label: `订单编号`, visible: true },
        { key: 1, label: `承租人`, visible: true },
        { key: 2, label: `取车信息`, visible: true },
        { key: 3, label: `还车信息`, visible: true },
        { key: 4, label: `押金方式`, visible: true },
        { key: 5, label: `租期/租金总额`, visible: true },
        { key: 6, label: `预定车型`, visible: true },
        { key: 7, label: `车牌号`, visible: true },
        { key: 8, label: `订单状态`, visible: true },
        { key: 9, label: `订单来源`, visible: true },
        { key: 10, label: `下单人`, visible: true },
        { key: 11, label: `订单标签`, visible: true },
        { key: 12, label: `业务员`, visible: true },
        { key: 13, label: `下单时间`, visible: true },
        { key: 14, label: `说明`, visible: true },
        { key: 15, label: `取消时间`, visible: false },
      ],
      active: 1,
      form: {
        orderNo: '', //订单编号
        carNo: '', //车牌号
        modelId: '', //预定车型id
        memberName: '', //客户名称
        memberType: '', //客户类型(字典:memberType)
        rentalTime: [], // 预定租赁时间
        reserveTakeStoreId: '', //预约取车门店
        reserveAlsoStoreId: '', //预约还车门店
        orderSource: '', //订单来源(字典:sys_order_source)
        orderStatus: '', //订单状态(字典:sys_order_status)
        takeStartTime: '',
        takeEndTime: '',
        alsoStartTime: '',
        alsoEndTime: '',
        startTime: '',
        endTime: '',
        labels: '',
        createBy: '',
        orderingPersonnelId: '',
        paymentStatus: '',
        modelName: ''
      },
      imgVisble: false,
      imgVisbleUrl: null,
      pageNum: 0, //页码   必选
      pageSize: 10, //每页显示数据 必选
      // 门店数据
      storeOptions: [],
      paymentOfFeesList: [],
      types: [],
      multiple: true,
      showPaymentOfFees: false,
      time: [],
      takeTime: [],
      alsoTime: [],
      actualTakeTime: [],
      actualAlsoTime: [],
      cancelTime: [],

      chargeItemsVo: [],
      loading: true,
      exportLoading: false,
      list: [],
      total: 0,
      type: 1,
      // 弹出层标题
      title: '',
      // 显示搜索条件
      showSearch: true,
      lineFolding: false,
      refundConfirmTitle: '',
      refundConfirmType: 3,
      // 是否显示弹出层
      nowOrderNo: null, // 当前选择订单id
      reserveTakeStoreId: null, // 当前选择订单id
      reserveAlsoStoreId: null, // 当前选择订单id
      nowSalesman: null, // 当前业务员
      open: false, // 显示新增/编辑
      scheduled: false, // 预定完成
      showorderRefund: false, // 显示订单退款
      showEarlyReturn: false, // 显示提前还车
      showChangeCar: false, // 显示订单换车
      showOrderRenewal: false, // 显示订单续租
      showSetLabel: false, // 显示设置标签
      showNewExpenses: false, // 显示租金调整
      showpeiche: false, // 显示配车
      showdingdanfenpei: false, // 显示订单分配
      showjiaocheyanche: false, // 显示交车验车
      showjiaocheyanchelist: false, // 显示交车验车单
      huancheyanche: false, // 显示还车验车
      huancheyanchelist: false, // 显示还车验车单
      showfeiyongmingxi: false, // 显示费用明细
      showdingdanlog: false, // 显示订单日志
      showVehicleDamage: false, // 显示车损结算明细
      showDepositRefund: false, // 显示押金结算退款
      showIllegalProcessing: false, // 显示违章处理明细
      showIllegalRefund: false, // 显示违章结算明细
      showDepositRefundConfirm: false, // 显示押金退款明细
      showProcessingConfirm: false, // 显示押金退款明细
      finalStatement: false // 显示结算单
    }
  },
  watch: {
    columns: {
      handler: function (val) {
        let username = Cookies.get('username');
        let tenantCode = Cookies.get('tenantCode');
        Cookies.remove(username + '-' + tenantCode + '-order-columns');
        Cookies.set(username + '-' + tenantCode + '-order-columns', JSON.stringify(val), { expires: 30 })
      },
      deep: true
    }
  },
  computed: {

    tenantId() {
      return this.$store.state.user.tenantId;
    },
    charterService() {
      const charterService = this.$store.state.user.charterService || 2;
      return charterService;
    },
  },
  mounted() {
    let username = Cookies.get('username');
    let tenantCode = Cookies.get('tenantCode');
    let columns = Cookies.get(username + '-' + tenantCode + '-order-columns');
    if (columns) {
      let arr = JSON.parse(columns);
      if (arr.length == this.columns.length) {
        this.columns = arr
      } else {
        let username = Cookies.get('username');
        let tenantCode = Cookies.get('tenantCode');
        Cookies.remove(username + '-' + tenantCode + '-order-columns');
        Cookies.set(username + '-' + tenantCode + '-order-columns', JSON.stringify(this.columns), { expires: 30 })
      }
    }
    this.$forceUpdate();
    let key = this.$route.query.key
    if (key) {
      this.orderTypeChange(key)
    } else {
      this.getList()
    }
    this.getOrderCount()
    this.getAllStore()
    this.getAllLabel()
    this.getUserList()
    this.getTenantInfo()
  },
  activated() {
    this.getOrderCount()
    this.getList()
  },
  methods: {
    // 获取租户是否开始电子合同
    getTenantInfo() {
      illegalQueryPriceDetail(this.tenantId).then(res => {
        this.electronicContractEnable = res?.data?.electronicContractEnable || 0;
      })
    },
    commitOrderRemark() {
      this.$refs.remarkForm.validate((valid) => {
        if (valid) {
          api.addOrderRemark(this.remarkForm).then(res => {
            this.dialogVisibleOrderRemark = false;
            this.$message({ type: 'success', message: '提交成功' });
            this.remarkForm.remarkContent = '';
            this.getList()
          })
        }
      })
    },
    checkPermi,
    tableRowClassName({ row, rowIndex }) {
      if (row.orderStatus === 10) {
        return 'cance-row';
      }
      return '';
    },
    getAllLabel() {
      getAllLabel().then((response) => {
        this.labelList = response.data
      })
    },
    /** 查询用户列表 */
    getUserList() {
      userlist({}).then((response) => {
        this.userList = response.data
        console.log(this.userlist)
      })
    },
    orderTypeChange(val) {
      this.active = val
        ; (this.type = val)
      this.getList()
    },
    /** 查询部门下拉树结构 */
    getAllStore() {
      getAllStore().then((response) => {
        this.storeOptions = response.data
      })
    },
    /** 排序触发事件 */
    handleSortChange(column, prop, order) {
      let sort = column.prop;
      let orderBy = column.order === 'descending' ? 'desc' : column.order === 'ascending' ? 'asc' : column.order;
      // this.getList(sort,orderBy)

      this.loading = true
      const params = {
        orderNo: this.form.orderNo, //订单编号
        modelId: this.form.modelId, //预定车型id
        carNo: this.form.carNo, //预定车型id
        memberName: this.form.memberName, //客户名称
        memberType: this.form.memberType, //客户类型(字典:memberType)
        reserveTakeStoreId: this.form.reserveTakeStoreId, //预约取车门店
        reserveAlsoStoreId: this.form.reserveAlsoStoreId, //预约还车门店
        orderSource: this.form.orderSource, //订单来源(字典:sys_order_source)
        orderStatus: this.form.orderStatus, //订单状态(字典:sys_order_status)
        pageNum: this.pageNum, //页码   必选
        pageSize: this.pageSize, //每页显示数据 必选
        type: this.type,
        createBy: this.form.createBy,
        labels: this.form.labels,
        orderingPersonnelId: this.form.orderingPersonnelId,
        paymentStatus: this.form.paymentStatus,
        modelName: this.form.modelName,

        startTime: this.form.startTime,//下单开始时间
        endTime: this.form.endTime,//下单结束时间

        takeStartTime: this.form.takeStartTime, //预定取车开始时间
        takeEndTime: this.form.takeEndTime, //预定取车结束时间
        alsoStartTime: this.form.alsoStartTime, //预定还车开始时间
        alsoEndTime: this.form.alsoEndTime, //预定还车结束时间

        actualTakeStartTime: this.form.actualTakeStartTime, //实际取车开始时间
        actualTakeEndTime: this.form.actualTakeEndTime, //实际取车结束时间
        actualAlsoStartTime: this.form.actualAlsoStartTime, //实际还车开始时间
        actualAlsoEndTime: this.form.actualAlsoEndTime, //实际还车结束时间

        cancelStartTime: this.form.cancelStartTime,//取消开始时间
        cancelEndTime: this.form.cancelEndTime,//取消结束时间

        sort: sort,
        order: orderBy
      }
      api.index(params).then((response) => {
        this.list = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 查询列表 */
    getList() {
      this.loading = true
      const params = {
        orderNo: this.form.orderNo, //订单编号
        modelId: this.form.modelId, //预定车型id
        carNo: this.form.carNo, //预定车型id
        memberName: this.form.memberName, //客户名称
        memberType: this.form.memberType, //客户类型(字典:memberType)
        reserveTakeStoreId: this.form.reserveTakeStoreId, //预约取车门店
        reserveAlsoStoreId: this.form.reserveAlsoStoreId, //预约还车门店
        orderSource: this.form.orderSource, //订单来源(字典:sys_order_source)
        orderStatus: this.form.orderStatus, //订单状态(字典:sys_order_status)
        pageNum: this.pageNum, //页码   必选
        pageSize: this.pageSize, //每页显示数据 必选
        type: this.type,
        createBy: this.form.createBy,
        labels: this.form.labels,
        orderingPersonnelId: this.form.orderingPersonnelId,
        paymentStatus: this.form.paymentStatus,
        modelName: this.form.modelName,

        startTime: this.form.startTime,//下单开始时间
        endTime: this.form.endTime,//下单结束时间

        takeStartTime: this.form.takeStartTime, //预定取车开始时间
        takeEndTime: this.form.takeEndTime, //预定取车结束时间
        alsoStartTime: this.form.alsoStartTime, //预定还车开始时间
        alsoEndTime: this.form.alsoEndTime, //预定还车结束时间

        actualTakeStartTime: this.form.actualTakeStartTime, //实际取车开始时间
        actualTakeEndTime: this.form.actualTakeEndTime, //实际取车结束时间
        actualAlsoStartTime: this.form.actualAlsoStartTime, //实际还车开始时间
        actualAlsoEndTime: this.form.actualAlsoEndTime, //实际还车结束时间

        cancelStartTime: this.form.cancelStartTime,//取消开始时间
        cancelEndTime: this.form.cancelEndTime,//取消结束时间
      }
      api.index(params).then((response) => {
        this.list = response.rows
        // this.list = this.list.map((item, index) => {
        //   if (index ==0){
        //     this.$set(item, 'orderClassify', 1)
        //     this.$set(item, 'isCheckCar', 2)
        //   }
        //   return item
        // })
        this.total = response.total
        this.loading = false
      })
    },
    getOrderCount() {
      api.orderCount().then((response) => {
        let orderCount = response.data
        this.tabs_list1 = [
          {
            key: '1',
            name: '全部',
            count: orderCount.allOrder
          },
          {
            key: '2',
            name: '待支付',
            count: orderCount.noPay
          },
          {
            key: '3',
            name: '待分配',
            count: orderCount.fp
          },
          {
            key: '4',
            name: '待排车',
            count: orderCount.pc
          },
          {
            key: '5',
            name: '待取车',
            count: orderCount.qc
          },
          {
            key: '6',
            name: '用车中',
            count: orderCount.yc
          },
          {
            key: '7',
            name: '结算中',
            count: orderCount.js + orderCount.tk
          },
          {
            key: '8',
            name: '已完成',
            count: orderCount.wc
          },
          {
            key: '9',
            name: '已取消',
            count: orderCount.qx
          }
          // {
          //   key: '10',
          //   name: '已退款',
          //   count: orderCount.tk,
          // },
        ]
        this.tabs_list2 = [
          {
            key: '111',
            name: '明日待取车',
            count: orderCount.tomorrowTakeCar
          },
          {
            key: '11',
            name: '今日待取车',
            count: orderCount.jrqc
          },
          {
            key: '131',
            name: '明日待还车',
            count: orderCount.tomorrowReturnCar
          },
          {
            key: '13',
            name: '今日待还车',
            count: orderCount.jrhc
          },
          {
            key: '12',
            name: '2小时内待取车',
            count: orderCount.twohqc
          },
          {
            key: '14',
            name: '2小时内待还车',
            count: orderCount.twohhc
          },
          {
            key: '15',
            name: '逾期未取车',
            count: orderCount.yqwq
          },
          {
            key: '16',
            name: '逾期未还车',
            count: orderCount.yqwh
          }
        ]
      })
    },
    // 更多操作触发
    handleCommand(command, row) {
      this.showOrderSelection = false
      switch (command) {
        case 'handleEdit':
          this.handleEdit(row)
          break
        case 'handleUpdateDriver':
          // this.$message.info('改派司机待开发')
          this.handleUpdateDriver(row)
          break
        case 'handleCancel':
          this.handleCancel(row)
          break
        case 'handleDingdan':
          this.handleDingdan(row)
          break
        case 'handlePeiche':
          this.handlePeiche(row)
          break
        case 'handleFeiyongmingxi':
          this.handleFeiyongmingxi(row)
          break
        case 'handleLog':
          this.handleLog(row)
          break
        case 'cargps':
          this.$router.push({
            name: 'Vehiclemonitoringpage',
            query: {
              id: row.carId,
            }
          })
          break
        case 'handleDetail':
          this.handleDetail(row)
          break
        case 'handleJiaocheyanche':
          this.handleJiaocheyanche(row)
          break
        case 'handleHuancheyanche':
          this.handleHuancheyanche(row)
          break
        case 'handleJiaocheyanchelist':
          this.handleJiaocheyanchelist(row)
          break
        case 'handleHuancheyanchelist':
          this.handleHuancheyanchelist(row)
          break
        case 'handleDelete':
          this.handleDelete(row)
          break
        case 'handleRevised':
          this.handleRevised(row)
          break
        case 'handleUpdateMember':
          this.handleUpdateMember(row)
          break
        case 'earlyReturn':
          this.earlyReturn(row)
          break
        case 'changeCar':
          this.changeCar(row)
          break
        case 'orderRenewal':
          this.orderRenewal(row)
          break
        case 'paymentOfFees':
          this.paymentOfFees(row)
          break
        case 'setLabel':
          this.setLabel(row)
          break
        case 'handleIllegalRefund':
          this.handleIllegalRefund(row)
          break
        case 'handleDepositRefund':
          this.handleDepositRefund(row)
          break
        case 'newExpenses':
          this.newExpenses(row)
          break
        case 'printContract':
          this.imgVisbleUrl = 'https://view.officeapps.live.com/op/view.aspx?src=' + this.getImgUrl(row.printContractUrl)
          this.imgVisble = true

          //window.open("https://view.officeapps.live.com/op/view.aspx?src="+this.getImgUrl(row.printContractUrl),'_blank')

          /* const url = btoa(row.printContractUrl)
          const path = '/order/orderBasic/showContract/'+ url +'/'+row.orderNo;
          console.log(path);
          this.$router.push({path}); */
          break

        case 'otaTakeCar'://ota订单交车验车
          this.$router.push({
            path: '/orderBasic/otaDelivery',
            query: { orderNo: row.orderNo, type: 1, carId: row.carId }
          })
          break;
          break
        case 'otaReturnCar'://ota订单还车验车
          this.$router.push({
            path: '/orderBasic/otaDelivery',
            query: { orderNo: row.orderNo, type: 2, carId: row.carId }
          })
          break;
          break
        case 'otaCostAdditional'://ota费用补录
          this.otaCostAddition(row)
          break
        default:
          break
      }
    },

    /** 搜索按钮操作 */
    handleQuery() {
      if (this.time) {
        this.form.startTime = this.time[0]
        this.form.endTime = this.time[1]
      } else {
        this.form.startTime = null
        this.form.endTime = null
      }
      if (this.takeTime) {
        this.form.takeStartTime = this.takeTime[0]
        this.form.takeEndTime = this.takeTime[1]
      } else {
        this.form.takeStartTime = null
        this.form.takeEndTime = null
      }
      if (this.alsoTime) {
        this.form.alsoStartTime = this.alsoTime[0]
        this.form.alsoEndTime = this.alsoTime[1]
      } else {
        this.form.alsoStartTime = null
        this.form.alsoEndTime = null
      }
      if (this.actualTakeTime) {
        this.form.actualTakeStartTime = this.actualTakeTime[0]
        this.form.actualTakeEndTime = this.actualTakeTime[1]
      } else {
        this.form.actualTakeStartTime = null
        this.form.actualTakeEndTime = null
      }
      if (this.actualAlsoTime) {
        this.form.actualAlsoStartTime = this.actualAlsoTime[0]
        this.form.actualAlsoEndTime = this.actualAlsoTime[1]
      } else {
        this.form.actualAlsoStartTime = null
        this.form.actualAlsoEndTime = null
      }
      console.log(this.cancelTime)
      if (this.cancelTime) {
        this.form.cancelStartTime = this.cancelTime[0]
        this.form.cancelEndTime = this.cancelTime[1]
      } else {
        this.form.cancelStartTime = null
        this.form.cancelEndTime = null
      }
      console.log(this.form.cancelStartTime)
      console.log(this.form.cancelEndTime)
      this.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetQueruyForm()
      this.handleQuery()
    },

    resetQueruyForm() {
      this.time = []
      this.takeTime = []
      this.alsoTime = []
      this.actualTakeTime = []
      this.actualAlsoTime = []
      this.cancelTime = []
      this.resetForm('queryForm')
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$modal.confirm('删除订单无法恢复,是否确认删除？')
        .then(function () {
          return api.removeOrder(row.orderNo)
        })
        .then(() => {
          this.getList()
          this.$modal.msgSuccess('删除成功')
        })
        .catch(() => {
        })
    },
    /** 调整订单按钮操作 */
    handleRevised(row) {
      api.getRevisedOrderData(row.orderNo).then((response) => {
        this.revisedOrderDataForm = {
          ...response.data
        }
      })
      this.revisedOrderDataForm.orderNo = row.orderNo
      this.revisedOrderDataFlag = true;
    },
    /** 修改客户信息按钮操作 */
    handleUpdateMember(row) {
      this.memberNo = row.memberNo
      this.editMemberInfo = true
    },
    ditMemberSubit() {
      try {
        this.$refs['MemberAdd'].validate().then((valid) => {
          if (valid) {
            this.submitLoading = true
            const form = this.$refs['MemberAdd'].emitData()
            updateBasic(form).then((response) => {
              this.$modal.msgSuccess('修改成功')
              this.editMemberInfo = false
              this.getList()
              this.submitLoading = false
            })
          }
        })
      } catch (error) {
        this.submitLoading = false
        this.$message.error(error.message)
      }
      setTimeout(() => {
        this.submitLoading = false
      }, 2e3)
    },

    doRevisedOrderData() {
      this.$refs["revisedOrderDataForm"].validate((valid) => {
        if (valid) {
          this.$modal.confirm('是否确认修改？')
            .then(() => {
              return api.doRevisedOrderData(this.revisedOrderDataForm);
            })
            .then(() => {
              this.getList()
              this.$modal.msgSuccess('操作成功')
              this.revisedOrderDataFlag = false;
            })
            .catch(() => {
            })
        }
      })

    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = '订单导入'
      this.upload.open = true
    },
    /** 下载模板操作 */
    importTemplate() {
      api.importTemplate().then((response) => {
        this.$download.name(response.msg)
      })
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false
      this.upload.isUploading = false
      this.$refs.upload.clearFiles()
      this.$alert(response.msg, '导入结果', {
        dangerouslyUseHTMLString: true
      })
      this.getList()
      this.getOrderCount()
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit()
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = {
        orderNo: this.form.orderNo, //订单编号
        modelId: this.form.modelId, //预定车型id
        carNo: this.form.carNo, //预定车型id
        memberName: this.form.memberName, //客户名称
        memberType: this.form.memberType, //客户类型(字典:memberType)
        reserveTakeStoreId: this.form.reserveTakeStoreId, //预约取车门店
        reserveAlsoStoreId: this.form.reserveAlsoStoreId, //预约还车门店
        orderSource: this.form.orderSource, //订单来源(字典:sys_order_source)
        orderStatus: this.form.orderStatus, //订单状态(字典:sys_order_status)
        pageNum: this.pageNum, //页码   必选
        pageSize: this.pageSize, //每页显示数据 必选
        type: this.type,
        createBy: this.form.createBy,
        labels: this.form.labels,
        orderingPersonnelId: this.form.orderingPersonnelId,
        paymentStatus: this.form.paymentStatus,
        modelName: this.form.modelName,

        startTime: this.form.startTime,//下单开始时间
        endTime: this.form.endTime,//下单结束时间

        takeStartTime: this.form.takeStartTime, //预定取车开始时间
        takeEndTime: this.form.takeEndTime, //预定取车结束时间
        alsoStartTime: this.form.alsoStartTime, //预定还车开始时间
        alsoEndTime: this.form.alsoEndTime, //预定还车结束时间

        actualTakeStartTime: this.form.actualTakeStartTime, //实际取车开始时间
        actualTakeEndTime: this.form.actualTakeEndTime, //实际取车结束时间
        actualAlsoStartTime: this.form.actualAlsoStartTime, //实际还车开始时间
        actualAlsoEndTime: this.form.actualAlsoEndTime, //实际还车结束时间

        cancelStartTime: this.form.cancelStartTime,//取消开始时间
        cancelEndTime: this.form.cancelEndTime,//取消结束时间

      }
      this.$modal
        .confirm('是否确认导出所有数据项？')
        .then(() => {
          this.exportLoading = true
          return api.exportBasic(queryParams)
        })
        .then((response) => {
          this.$download.name(response.msg)
          this.exportLoading = false
        })
        .catch(() => {
        })
    },

    /** 取消按钮操作 */
    handleCancel(row) {
      // if (row.rentIspay == 1 && row.depositIspay == 1 && row.illegalIspay == 1) {
      //   const ids = row.orderNo || this.ids
      //   this.$modal
      //     .confirm('是否确认取消吗？')
      //     .then(function () {
      //       return api.cancelAndRefund({ orderNo: ids })
      //     })
      //     .then(() => {
      //       this.getList()
      //       this.getOrderCount()
      //       this.$modal.msgSuccess('取消成功')
      //     })
      //     .catch(() => {})
      // } else {
      this.nowOrderNo = row.orderNo
      this.showorderRefund = true
      // }
    },

    /** 提前退车 */
    earlyReturn(row) {
      this.nowOrderNo = row.orderNo
      this.$router.push({
        path: '/orderBasic/earlyReturn',
        query: { orderNo: row.orderNo, carId: row.carId, control: row.control },
      })
    },
    /** 订单换车 */
    changeCar(row) {
      this.nowOrderNo = row.orderNo
      this.$router.push({
        path: '/orderBasic/changeCar',
        query: { orderNo: row.orderNo },
      })
    },
    /** 订单续租 */
    orderRenewal(row) {
      this.nowOrderNo = row.orderNo
      this.showOrderRenewal = true
    },
    /** 设置标签 */
    setLabel(row) {
      // this.setLabelData.labels=row.labels?.split(",").map(i=>{
      //   return Number(i)
      // })

      this.setLabelData.labels = this.labelList.map(i => i.id).filter(item => {
        return row.labels?.split(",").indexOf(item + "") >= 0
      })
      this.nowOrderNo = row.orderNo
      this.showSetLabel = true
    },
    /** 租金调整 */
    newExpenses(row) {
      this.nowOrderNo = row.orderNo
      // this.chargeItemsVo = []
      // this.addChargingItems()
      this.showNewExpenses = true
    },
    /** 费用补录 */
    otaCostAddition(row) {
      this.nowOrderNo = row.orderNo
      this.$router.push({ name: 'OtaCostAdditional', query: { orderNo: this.nowOrderNo } })
    },
    /** 费用缴纳 */
    paymentOfFees(row) {
      this.showPaymentOfFees = true
      this.nowOrderNo = row.orderNo
      api.getAllPaymentOfFees(row.orderNo).then((res) => {
        this.paymentOfFeesList = res.data
      })
    },

    // 费用缴纳多选框选中数据
    handleSelectionChange(selection) {
      this.types = selection.map((item) => item.type)
      this.multiple = !selection.length
    },
    selectable(row, index) {
      return Number(row.unpaidAmount) > 0 && Number(row.payStatus) == 1
    },
    // 立即缴费
    payImmediately() {
      this.showPaymentOfFees = false
      // this.$router.push({
      //   path: '/orderBasic/orderPayRecord',
      //   query: { orderNo: this.nowOrderNo, types: this.types.join(',') }
      // })
      this.$router.push({ name: 'OrderPayRecord', params: { orderNo: this.nowOrderNo, types: this.types.join(','), source: "1" } })
    },
    formatLabel(labels) {
      return this.labelList.filter(item => {
        return labels?.split(",").indexOf(item.id + "") >= 0
      }).map(i => {
        return i.name
      }).join(",")
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.nowOrderNo = null
      this.$router.push({ path: '/orderBasic/add' })
    },
    toRevenueStatistics() {
      this.$router.push({ path: '/record/revenueStatistics/VehicleRevenue' });
    },
    /** 编辑按钮操作 */
    handleEdit(row) {
      //点击编辑页面
      this.nowOrderNo = row.orderNo
      this.$router.push({
        path: '/orderBasic/edit',
        query: { orderNo: row.orderNo }
      })
    },
    /** 订单详情按钮 */
    handleDetail(row) {
      this.nowOrderNo = row.orderNo
      if (row.orderClassify == 1) {
        this.$router.push({
          path: '/orderBasic/otaOrderDetail',
          query: { orderNo: row.orderNo }
        })
      } else {
        this.$router.push({
          path: '/orderBasic/detail',
          query: { orderNo: row.orderNo }
        })
      }


    },
    handleUpdateDriver(row) {
      this.nowOrderNo = row.orderNo
      this.reserveTakeStoreId = row.reserveTakeStoreId
      this.showDriver = true;
    },
    // 改派司机
    updateDriver(driverInfo) {
      api.rescheduleDriver({
        orderNo: this.nowOrderNo,
        substituteDrivingId: driverInfo.userId,
        substituteDrivingName: driverInfo.nickName,
      }).then(res => {
        if (res.code == 200) {
          this.$message.success('改排司机成功');
          this.handleQuery();
        }
      })
    },
    /** 配车 */
    handlePeiche(row) {

      if (row.orderClassify == 1) {
        if (checkPermi(['order:otaOrder:dispatchCar'])) {
          this.nowOrderNo = row.orderNo
          this.xbRent = row.rent
          this.xbLeaseDays = row.leaseDays
          this.showpeiche = true
        }
      } else {
        if (row.orderStatus < 4 && checkPermi(['order:orderBasic:supplyCar'])) {
          this.nowOrderNo = row.orderNo
          this.xbRent = row.rent
          this.xbLeaseDays = row.leaseDays
          this.showpeiche = true
        }
      }
    },
    /** 订单日志 */
    handleLog(row) {
      this.nowOrderNo = row.orderNo
      this.showdingdanlog = true
    },
    /** 订单分配 */
    handleDingdan(row) {
      if (row.orderClassify == 1) {
        this.nowOrderNo = row.orderNo
        this.reserveTakeStoreId = row.reserveTakeStoreId
        this.reserveAlsoStoreId = row.reserveAlsoStoreId
        this.showdingdanfenpei = true
      } else if (row.orderStatus < 5 && checkPermi(['order:orderBasic:distribution'])) {
        this.nowOrderNo = row.orderNo
        this.reserveTakeStoreId = row.reserveTakeStoreId
        this.reserveAlsoStoreId = row.reserveAlsoStoreId
        this.showdingdanfenpei = true
      }
    },
    /** 费用明细 */
    handleFeiyongmingxi(row) {
      this.nowOrderNo = row.orderNo
      this.showfeiyongmingxi = true
    },
    /** 交车验车 */
    handleJiaocheyanche(row) {
      api.deliveryInspection({ orderNo: row.orderNo, type: 1 }).then(res => {
        switch (res.data.code) {
          case 0:
            this.$router.push({
              path: '/orderBasic/delivery',
              query: { orderNo: row.orderNo, type: 1, control: row.control, carId: row.carId }
            })
            break;
          case 1:
            this.$confirm(res.data.msg, '提示', {
              confirmButtonText: '反欺诈',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.$router.push({ name: 'creditAdd', query: { type: 1, memberNo: row.memberNo } })
            })
            break;
          case 2:
            this.$confirm(res.data.msg, '提示', {
              confirmButtonText: "查看",
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.$router.push({ name: 'creditDetail', query: { id: res.data.id } });
            })
            break;
          case 3:
          case 4:
          case 5:
            this.$confirm(res.data.msg, '提示', {
              confirmButtonText: '电子合同',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.nowOrderNo = row.orderNo
              this.$router.push({
                path: '/orderBasic/detail',
                query: { orderNo: row.orderNo, tabIndex: "4" }
              })
            })
            break;
        }
      })


    },
    /** 交车验车单 */
    handleJiaocheyanchelist(row) {
      this.nowOrderNo = row.orderNo
      this.showjiaocheyanchelist = true
    },
    /** 还车验车 */
    handleHuancheyanche(row) {
      this.$router.push({
        path: '/orderBasic/returnTheCar',
        query: { orderNo: row.orderNo, type: 2, control: row.control, carId: row.carId }
      })
    },
    /** 还车验车单 */
    handleHuancheyanchelist(row) {
      this.nowOrderNo = row.orderNo
      this.huancheyanchelist = true
    },
    /** 车损结算 */
    handleVehicleDamage(row) {
      this.nowOrderNo = row.orderNo
      this.showVehicleDamage = true
    },
    /** 押金结算退款 */
    handleDepositRefund(row) {
      this.nowOrderNo = row.orderNo
      let that = this
      api.orderCostIspay(that.nowOrderNo, 1).then((res) => {
        if (res.data.code === 1 || row.orderStatus === 5) {
          let title = [];
          const h = this.$createElement;
          if (res.data.code === 1 && row.orderStatus === 5) {
            title = [
              h('span', null, '1、请确保无车损需处理后进行此操作'),
              h('br', null, null),
              h('span', null, "2、" + res.data.title),
            ]
          } else if (res.data.code === 1 && row.orderStatus !== 5) {
            title = [
              h('span', null, res.data.title)
            ]
          } else if (res.data.code !== 1 && row.orderStatus === 5) {
            title = [
              h('span', null, '请确保无车损需处理后进行此操作')
            ]
          }
          this.$msgbox({
            title: '消息',
            message: h('p', null, title),
            showCancelButton: true,
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            beforeClose: (action, instance, done) => {
              done();
            }
          }).then(action => {
            that.showDepositRefund = true
          });
        } else {
          that.showDepositRefund = true
        }
      })
    },
    /** 违章处理 */
    handleIllegalProcessing(row) {
      this.nowOrderNo = row.orderNo
      this.showIllegalProcessing = true
    },
    /** 违章押金结算 */
    handleIllegalRefund(row) {
      this.nowOrderNo = row.orderNo
      let that = this
      api.orderCostIspay(that.nowOrderNo, 2).then((res) => {
        if (res.data.code === 1 || row.orderStatus === 7) {
          let title = [];
          const h = this.$createElement;

          if (res.data.code === 1 && row.orderStatus === 7) {
            title = [
              h('span', null, '1、请确保无违章信息需处理后进行此操作'),
              h('br', null, null),
              h('span', null, "2、" + res.data.title),
            ]
          } else if (res.data.code === 1 && row.orderStatus !== 7) {
            title = [
              h('span', null, res.data.title)
            ]
          } else if (res.data.code !== 1 && row.orderStatus === 7) {
            title = [
              h('span', null, '请确保无违章信息需处理后进行此操作')
            ]
          }

          this.$msgbox({
            title: '消息',
            message: h('p', null, title),
            showCancelButton: true,
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            beforeClose: (action, instance, done) => {
              done();
            }
          }).then(action => {
            that.showIllegalRefund = true
          });

        } else {
          that.showIllegalRefund = true
        }
      })
    },
    /** 违章结算 */
    handleSettlement2(row) {
      this.nowOrderNo = row.orderNo
      this.showsettlement2 = true
    },
    /** 违章结算单 */
    showFinalStatement(row) {
      this.nowOrderNo = row.orderNo
      this.finalStatement = true
    },
    /** 通用关闭弹窗处理方法 */
    closeDiolog(flag) {
      this.nowOrderNo = null
      if (flag) {
        this.getList()
        this.getOrderCount()
      }
    },
    /** 提交订单 */
    submitForm() {
      this.addLoadIng = true
      const form = this.$refs?.MmvAdd?.emitData() || {}
      if (form.orderNo) {
        api
          .put(form)
          .then((response) => {
            this.scheduledData = response.data
            this.scheduled = true
          })
          .finally((f) => {
            this.addLoadIng = false
          })
      } else {
        api
          .add(form)
          .then((response) => {
            this.scheduledData = response.data
            this.scheduled = true
          })
          .finally((f) => {
            this.addLoadIng = false
          })
      }
    },
    toSetLabel() {
      this.setLabelData.orderNo = this.nowOrderNo;
      api.setOrderLabels(this.setLabelData)
        .then((response) => {
          this.showSetLabel = false
        })
    },
    // addChargingItems() {
    //   this.chargeItemsVo.push({
    //     chargeProjectName: '',
    //     unitPrice: 0,
    //     chargeItemsType: 1,
    //     number: 1,
    //     canEdit: 3,
    //     chargeMoney: 0,
    //   })
    // },
    // deleteChargingItems(row) {
    //   const index = this.chargeItemsVo.map(f => f.chargeProjectName).indexOf(row.chargeProjectName);
    //   this.chargeItemsVo.splice(index, 1)
    // },
    // addNewExpenses(){
    //   if(this.testItemsVo()){
    //     api.addNewExpenses({orderNo:this.nowOrderNo,chargeItemsVo:this.chargeItemsVo}).then(res=>{
    //       this.showNewExpenses = false
    //     })
    //   }
    // },
    // testItemsVo(){
    //   if (this.chargeItemsVo){
    //     for (let item of this.chargeItemsVo) {
    //       if (!item.chargeProjectName) {
    //         this.$message.error('费用项名称不能为空')
    //         return false;
    //       }
    //       if (!item.unitPrice) {
    //         this.$message.error('单价不能为空且应大于零')
    //         return false;
    //       }
    //       if (!item.chargeItemsType) {
    //         this.$message.error('请选择费用类型')
    //         return false;
    //       }
    //       if (!item.number) {
    //         this.$message.error('数目不能为空且应大于零')
    //         return false;
    //       }
    //     }
    //     return true
    //   }else{
    //     this.$message.error('费用项不能为空')
    //     return false;
    //   }
    //
    // }
  }
}
</script>
<style scoped>
.scheduled .el-form-item {
  margin-bottom: 0 !important;
}

/deep/ .uploadBox .el-dialog__body {
  text-align: center;
}

/deep/ .el-table .cance-row {
  background: #f2f2f2;
  /*color: #999 !important;*/
}


.oederNo-badge {
  width: 20px;
  height: 20px;
  position: absolute;
  top: 0px;
  right: 0px;
}

.oederNo-badge-red {
  border-left: 40px solid #ffffff00;
  border-top: 40px solid #ababab;
}

.oederNo-badge-green {
  border-left: 40px solid #ffffff00;
  border-top: 40px solid #819ff2;
}

.oederNo-badge-text {
  width: 20px;
  height: 20px;
  position: absolute;
  top: -1px;
  right: -1px;
  color: white;
  font-weight: bold;
}

.min-box {
  overflow: hidden;
  height: 40px
}

.car_no {
  margin: 2px 0;
  height: 24px;
  width: 90px;
  box-sizing: border-box;
  color: white;
  font-weight: bold;
  background-color: #1e68bb;
  border-radius: 3px;
  border: white 0.5px solid;
  text-align: center;
  padding: 2px 0px;
  display: inline-block;
  box-shadow: 0 0 1px 2px #1e68bb;
}

.car_no_new {
  margin: 2px 0;
  height: 24px;
  width: 90px;
  color: #000000;
  font-weight: bold;
  background-image: linear-gradient(to top, #12c53e, #ffffff);
  border-radius: 3px;
  border: #000000 0.5px solid;
  text-align: center;
  padding: 2px 0px;
  display: inline-block;
  box-shadow: 0 0 1px 2px #85c085;
}

.dian {
  user-select: none;
}
</style>
